package org.luffhat.handler;

import lombok.extern.slf4j.Slf4j;
import org.luffhat.response.R;
import org.luffhat.response.ResultCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description
 * @Author ljb
 * @Date 2022-01-14
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody //为了返回数据
    public R error(Exception e){
        log.error("异常",e);
        return R.fail(ResultCode.INTERNAL_SERVER_ERROR);
    }
}
